package com.xh.bgc.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.xh.bgc.dao.UserInfoMapper;
import com.xh.bgc.pojo.UserInfo;
import com.xh.bgc.services.UserInfoServices;
import com.xh.bgc.util.EmailTest;
import com.xh.bgc.util.Mycons;

@Controller
@RequestMapping(value="/userInfo")
public class UserInfoController {

	@Autowired
	private UserInfoServices userInfoBiz;
	@Autowired
	private UserInfoMapper mapper;
	
	
	@RequestMapping(value="/userLogin")
	public String UserLogin(@RequestParam String phone,@RequestParam String password,HttpSession session){
		
		EmailTest email =new EmailTest();
		UserInfo userInfo = userInfoBiz.userLogin(phone, password);
		
		if(null !=userInfo){
			session.setAttribute(Mycons.User_Info, userInfo);
				EmailTest.sendEmail();
			
	System.out.println();
		}
		return "redirect:/jsp/index.jsp";
	}
	
	/**
	 * 
	 * @param userInfo
	 * @return
	 * 注册
	 */
	@RequestMapping(value="/userRegister")
	public String userRegister(UserInfo userInfo,@RequestParam String password,@RequestParam String password1){
		int i = userInfoBiz.userRegister(userInfo);
		if(i>0&&password1.equals(password)){
			return "index";
		}else{
			return "Error";
			
		}
				
	}
	
	@RequestMapping(value="/update")
	public String updatePwd(@RequestParam String phone,HttpSession session){
		
		return "";
	}
}
